<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>个人资料</title>
<link href="/css/base.css" type="text/css" rel="stylesheet" />
<link href="/css/manage.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery.default.js"></script>
<script type="text/javascript" src="/js/jquery.validate.js"></script>
<script type="text/javascript" src="/js/jquery.form.js"></script>
<!--[if ie]><link href="/css/ie.css" type="text/css" rel="stylesheet"><![endif]-->


</head>

<body>
   <?php $this->load->view('head');?>
    <!-- head--end-->
    <?php $data['curstyle'] = 'memberinfo'?>
    <!-- body -->
    <div class="w100p mt40 mb20">
    	<div class="w903 mg">
        	<div class="box_s1">
            	<div class="b_head"></div>
                <div class="content m_pd_s1">
                	<!-- manage-top -->
                	<?php $this->load->view('member/mangtop',$data)?>
                    <!-- manage-top--end-->
                    
                    <!-- manage-det-->
                   <div class="clearfix">
                    	<div class="box_s3 fl">
                        	<div class="b_head"></div>
                            <?php $data['leftstyle'] = 'avatar'?>
                            <?php $this->load->view('member/memberinfoleft',$data)?>
                            <div class="b_foot"></div>
                        </div>
                        
                        <!-- right-ope-->
                        <div class=" m_layout_s1">
                        	<div class="m_pd_s4">
                            	<div class="form_box">
                                    <form action="<?php echo site_url('member/uploadavatar')?>" method="post" enctype="multipart/form-data" id='avatar_form'>
                                    	<div class="avater_box">
                                        	<img src="<?php echo site_url($avatar)?>"  id='avatar_img' url='<?php echo $avatar?>' class="block" width="196" height="196"/>
                                        </div>
                                        
                                        <table class="com_form com_form_s1 mt10 p_upload ">
                                            <tbody>
                                                <tr>
                                                    <td class="col1">选择图片</td><td><input type="text" class="def_txt_s4" id="photo_text" /><div class="upfile_wrap"><a href="javascript:void(0);" class="def_btn_s10 upload ml10">browse</a><input type="file" class=" opacity_file" name="avatar" onchange="upload_avatar(this);"/></div><input type="button" id="save_avatar" class="def_btn_s10 ml10 save" value="保 存" /></a>
                                                    <br /><span class=" tip_3">支持jpg,gif格式照片尺寸196x196px</span></td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <!-- right-ope--end-->
                        
                        <div class="clear"></div>
                    </div>
                    <!-- manage-det--end-->
                    
                </div>
                <div class="b_foot"></div>
            </div>
        </div>
    </div>
    <!-- body--end-->
    
    <!-- foot-->
   <?php $this->load->view('foot')?>
    <!-- foot--end-->	
</body>
<script type="text/javascript">
	function upload_avatar(obj){
		var file_name = $(obj).val();
		$("#photo_text").val(file_name);
		$("#avatar_form").ajaxSubmit(function(data){
				var ret = $.parseJSON(data);
				$("#avatar_img").attr("src",'<?php echo site_url()?>'+ret.image_url);
				$("#avatar_img").attr("url",ret.image_url);
			});
	}

	$(function(){
		$("#save_avatar").click(function(){
			$.post("<?php echo site_url('member/saveavatar')?>",
					{'avatar':$("#avatar_img").attr("url")},
				function(data){
					alert("保存成功");
				}
			)
		})
	});
	
</script>
</html>
